package com.liang.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

@Configuration
@EnableSwagger2WebMvc
@Slf4j
public class Knife4jConfig {

	@Value("${server.port}")
	private String port;

	@Value("${spring.application.name}")
	private String appName;

	//http://localhost:8195/lsd-mca/doc.html


	@Bean(value = "defaultApi2")
	public Docket defaultApi2() {
		String url = "http://localhost:" + port + "/"+appName;
		log.info("-----------------"+url+"/doc.html");
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(new ApiInfoBuilder()
						.description("api文档")
						.termsOfServiceUrl(url)
						.version("1.0")
						.build())
				.groupName("平台管理")
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.liang.controller"))
				.paths(PathSelectors.any())
				.build();
	}

}
